import cv2
import numpy as np

# 图片路径
#img = cv2.imread('F:\P_008.jpg')

img = cv2.imdecode(np.fromfile('F:\\剪切gu\\P_005.jpg', dtype=np.uint8), -1)
a = []
b = []


def on_EVENT_LBUTTONDOWN(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
        xy = "%d,%d" % (x, y)
        a.append(x)
        b.append(y)
        cv2.circle(img, (x, y), 1, (0, 0, 255), thickness=-1)
        cv2.putText(img, xy, (x, y), cv2.FONT_HERSHEY_PLAIN,
                    1.0, (0, 0, 0), thickness=1)
        cv2.imshow("image", img)

h, w = img.shape[:2]
cv2.namedWindow("image", cv2.WINDOW_FULLSCREEN) #WINDOW_AUTOSIZE
"""

WINDOW_NORMAL
WINDOW_AUTOSIZE v
WINDOW_OPENGL
WINDOW_FULLSCREEN v
WINDOW_FREERATIO
WINDOW_KEEPRATIO
WINDOW_GUI_NORMAL
WINDOW_GUI_EXPANDED
"""
h,f =img.shape[:2]
cv2.resizeWindow('image', (300,300))
print(f'h:{h},f:{f}')
cv2.setMouseCallback("image", on_EVENT_LBUTTONDOWN)
cv2.imshow("image", img)
cv2.waitKey(0)
print(a[0], b[0])

cv2.destroyAllWindows()